import sys
import os

sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from utils import ConfigLoader, LOG
from model import GLMModel, OpenAIModel, ZhipuAIModel
from translator import PDFTranslator

def ai_translator(pdf_file_path, source_language, language):
    # argument_parser = ArgumentParser()
    # args = argument_parser.parse_arguments()
    config_loader = ConfigLoader(config_path='config.yaml')

    config = config_loader.load_config()

    model_name = config['OpenAIModel']['model']
    api_key = config['OpenAIModel']['api_key']
    model = ZhipuAIModel(model=model_name, api_key=api_key)
    # Initalize the model.

    # 实例化 PDFTranslator 类，并调用 translate_pdf() 方法
    translator = PDFTranslator(model)
    # translator.translate_pdf(pdf_file_path=pdf_file_path, target_language=language)
    return translator.translate_pdf(pdf_file_path=pdf_file_path, target_language=language)
